#ARCH	:= arm-linux-
CXX		:= $(ARCH)g++
CC		:= $(ARCH)gcc
STRIP	:= $(ARCH)strip
SUBDIR	:= afn net manager sqlite modbus common include
HPP		:= $(shell find $(SUBDIR) | grep "\.h$$")
CSRC	:= $(shell find $(SUBDIR) | grep "\.c$$")
XSRC	:= $(shell find $(SUBDIR) | grep "\.cpp$$")
OBJ		:= $(patsubst %.cpp, %.o, $(XSRC))
OBJ		+= $(patsubst %.c,   %.o, $(CSRC))
CFLAGS	:= $(patsubst %,-I%, $(SUBDIR))
LDFLAGS	:= -lACE -ldl -lpthread 

all: test.exe login.exe
	#$(STRIP) $+
	@ls -sh $+
arm:
	make -f makefile.arm
test.exe: $(OBJ) $(HPP) ztest/test.o
	$(CXX) $(CFLAGS) $(LDFLAGS) $(OBJ) ztest/test.o -o $@
login.exe: $(OBJ) $(HPP) ztest/login.o
	$(CXX) $(CFLAGS) $(LDFLAGS) $(OBJ) ztest/login.o -o $@
%.o:%.cpp
	$(CXX) $(CFLAGS)  -std=c++11 $+ -c -o $@
%.o:%.c
	$(CC) $(CFLAGS) $+ -c -o $@ 
clean:
	@rm -rvf $(OBJ) *.exe ztest/*.o
